GMutex mutex_data;
GMutex *mutex;
+ GstClock *clock;
+ GstClockTime last_frame_time;
+
GstCaps *caps;
GAsyncQueue *queue;
gboolean closed;
shell_recorder_src_init (ShellRecorderSrc *src)
{
gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME);
+ gst_base_src_set_live (GST_BASE_SRC (src), TRUE);
+
+ src->clock = gst_system_clock_obtain ();
+ src->last_frame_time = 0;
src->queue = g_async_queue_new ();
src->mutex = &src->mutex_data;
return GST_FLOW_EOS;
buffer = g_async_queue_pop (src->queue);
+
+ if (src->last_frame_time == 0)
+ src->last_frame_time = gst_clock_get_time (GST_CLOCK (src->clock));
+
if (buffer == RECORDER_QUEUE_END)
{
/* Returning UNEXPECTED here will cause a EOS message to be sent */
- (int)(gst_buffer_get_size(buffer) / 1024));
*buffer_out = buffer;
+ GST_BUFFER_DURATION(*buffer_out) = GST_CLOCK_DIFF (src->last_frame_time, gst_clock_get_time (GST_CLOCK (src->clock)));
+
+ src->last_frame_time = gst_clock_get_time (GST_CLOCK (src->clock));
return GST_FLOW_OK;
}
g_mutex_clear (src->mutex);
+ gst_object_unref (src->clock);
+
G_OBJECT_CLASS (shell_recorder_src_parent_class)->finalize (object);
}